<?php
    session_start();
    include("../include/util.inc.php");
    /****************************
    *Function name: deleteQuz
    *Description: Delete the corresponding question in the 
                    database according to the question id.
    *Parameters: questionId
    *Return: null
    *******************************/
    function deleteQuz($questionId)
    {
        $pdo = getPDO();
        $sql = "DELETE FROM question WHERE id='$questionId'";
        $pdo->exec($sql);
    }
    /** 
    *Description: Receive the id of question 
    *submitted by js and call the function to delete it.
    */
    try {
        $questionId = $_POST['quzid'];
        echo $questionId;
        deleteQuz($questionId);
        echo "success";
    } catch (\PDOException $e) {
        echo $e->getMessage();
    }
?>